<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<jsp:include page="../head.jsp">
<jsp:param value="创建订单" name="title"/>
</jsp:include>
<script type="text/javascript">
		function money(){
			var totalMoney = document.getElementById("totalMoney").value;
			var recordNowpaid = document.getElementById("recordNowpaid").value;
			var reg = /^[0-9]*$/; //只出现0-9之间的数字
			if(!reg.test(recordNowpaid)){
				document.getElementById("reds").innerText("你输入的不是数字");
				return;
			}
			
			//data-old设置一个默认值，在原先值得基础上进行叠加
			var recordPaid = document.getElementById("recordPaid").dataset.old;
			//只有在有值的情况下才能操作，若是输入值之后删掉，仍然可以回到之前状态
			if(recordNowpaid){
				recordPaid = parseFloat(recordPaid) + parseFloat(recordNowpaid);
			}

			document.getElementById("recordPaid").value = parseFloat(recordPaid);
			
			//自动变化未交的金额
			document.getElementById("recordUnpaid").value = parseFloat(totalMoney) - parseFloat(recordPaid);
			
			//判断是否缴清
			if(document.getElementById("recordUnpaid").value == 0.0){
				document.getElementById("paidall").value = "是";
			}else if(document.getElementById("recordUnpaid").value < 0.0){
				document.getElementById("reds").innerText("你输入的金额错误");
				return;
			}else{
				document.getElementById("paidall").value = "否";
			}
		}
		
</script>
</head>
<body>
	<div class="container">
		<div class="row">
			<div id="content" class="col-lg-9">
				<div class = "dao">		
					<a class="section" href = "manager">学员管理</a>
					<i class="right chevron icon divider"></i>
					<a class="section" href = "student">收款管理</a>
					<i class="right chevron icon divider"></i>
					<span class="active section">创建订单</span>							
				</div>
				
				<div class="col-md-12">
				<!-- BOX -->
				<div class="box border blue" id="formWizard">
					<div class="box-title">
						<h4><i class="fa fa-bars"></i>新增交易记录</h4>
						<div class="tools hidden-xs">
							<a href="#box-config" data-toggle="modal" class="config">
								<i class="fa fa-cog"></i>
							</a>
							<a href="javascript:;" class="reload">
								<i class="fa fa-refresh"></i>
							</a>
							<a href="javascript:;" class="collapse">
								<i class="fa fa-chevron-up"></i>
							</a>
							<a href="javascript:;" class="remove">
								<i class="fa fa-times"></i>
							</a>
						</div>
					</div>
					<div class="box-body form">
						<form method = "post" class="form-horizontal" novalidate="novalidate">
						<div class="wizard-form">
						   <div class="wizard-content">
							  <div class="tab-content">
								 <div >
									<div class="form-group">
									   <label class="control-label col-md-3">姓名<span class="required">*</span></label>
									   <div class="col-md-4">
										  <input type="text" value="${orderVo.orderCustName}" class="form-control" name="orderCustName" readonly = "readonly">
									   </div>
									</div>
									<div class="form-group">
									   <label class="control-label col-md-3">应交金额<span class="required">*</span></label>
										 <div class="col-md-4">	
											<input type="text" id = "totalMoney"	onkeyup = "money()" value="${empty records?15000:records.recordTotalmoney}" name="recordTotalmoney" readonly = "readonly" class="form-control" >
									   </div>
									</div>
									<div class="form-group">
									   <label class="control-label col-md-3">已交金额</label>
									   <div class="col-md-4">
										  <input type="text" class="form-control" data-old="${empty records?0:records.recordPaid}" name="recordPaid" 
										id = "recordPaid" value="${empty records?0:records.recordPaid}">
									   </div>
									</div>
									<div class="form-group">
									   <label class="control-label col-md-3">本次交的金额</label>
									   <div class="col-md-4">
										  <input class="form-control" onkeyup = "money()" id = "recordNowpaid">
									   </div>
									</div>
									
									<div class="form-group">
									   <label class="control-label col-md-3">未交金额</label>
									   <div class="col-md-4">
										  <input class="form-control" name="recordUnpaid" type="text" 
										id = "recordUnpaid" value = "${records.recordUnpaid}">
									   </div>
									</div>
									
									<div class="form-group">
									   <label class="control-label col-md-3">收款人<span class="required">*</span></label>
									   <div class="col-md-4">
										  <select name="recordPayee" value="${param.degree }" class="form-control col-md-12 full-width-fix select2-offscreen" tabindex="-1">
											 <c:forEach items = "${employee }" var = "emp">
												 <option value="${emp.empId }">${emp.empId }</option>
											 </c:forEach>
										  </select>
									   </div>													
									</div>
									
									<div class="form-group">
										<label class="control-label col-md-3">费用是否已交全</label>
									   <div class="col-md-4">
										  <input class="form-control" name="paidall" type="text" id = "paidall" readonly="readonly" value = "否">
									   </div>
									</div>
									<div class="form-group">
									   <label class="control-label col-md-3">是否贷款<span class="required">*</span></label>
									   <div class="col-md-4">
										  <select name="loan" value="${records.loan}" class="form-control col-md-12 full-width-fix select2-offscreen" tabindex="-1">
											 <option value="1">是</option>
											 <option value="0">否</option>
										  </select>
									   </div>													
									</div>
									
									<div class="form-group">
									   <label class="control-label col-md-3">学生状态</label>
									   <div class="col-md-4">
										  <input class="form-control" name="customStatus" type="text" id = "customStatus" value="${orderVo.customStatus}">
										
									   </div>
									</div>
									<div class="form-group">
									   <div class="col-md-4">
										  <input  class="form-control"  type="hidden" name="sid" value="${orderVo.orderId }">
										  <input  class="form-control"  type="hidden" name="recordPaidtime" value="${empty records?'0000-00-00':records.recordPaidtime }">
									   </div>
									</div>
									
								 </div>
							  </div>
						   </div>
						   
						</div>
						<button class="btn btn-primary" style = "left:200px;position: relative; width: 100px;">创建</button>  <span style = "color:red;position:relative;left:200px;">${error}</span>
					 </form>
					</div>
				</div>
			</div>
		 </div>
			</div>
			</div>
		</div>
	</div>
</body>
</html>